/*
 * @Description: 工具类
 * @Autor: 万洲
 * @Date: 2022-10-20 10:26:55
 * @LastEditors: 万洲
 * @LastEditTime: 2022-11-21 14:56:01
 */
import { ElMessage } from "element-plus"
import modollar from "mdollar"
class wzUtilsClass {
    /**
     * 加载
     * @param message 
     */
    showLoading = (message: string = '加载中...') => {
    }
    /**
     * 停止加载 
     */
    hideLoading = () => { }
    /**
     * 消息提示
     * @param message 消息内容
     * @param type 消息类型默认成功
     * @returns 
     */
    showToast = (message: string = "操作成功", type: "error" | "success" | "warning" | "info" = "success") => ElMessage({ message, type })
    formatDateRange = (params:any, dateRange:any, propName?:any) => {
        let search = params;
        search.params = typeof (search.params) === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {};
        dateRange = Array.isArray(dateRange) ? dateRange : [];
        if (typeof (propName) === 'undefined') {
          search.params['beginTime'] = dateRange[0];
          search.params['endTime'] = dateRange[1];
        } else {
          search.params['begin' + propName] = dateRange[0];
          search.params['end' + propName] = dateRange[1];
        }
        return search;
    }
}

const wzUtils: wzUtilsClass & typeof modollar = new wzUtilsClass() as any
// 合并utils
for (const key in modollar) {
    wzUtils[key] = modollar[key]
}
export default wzUtils